#include<bits/stdc++.h>
using namespace std;
#define int long long

int marks[35];
int ans[10];

signed main() {
	int n;
	cin >> n;

	int t;
	for (int i = 1; i <= 7; i++) {
		cin >> t;
		marks[t] = 1;
	}

	while (n--) {
		int cnt = 0;
		for (int i = 1; i <= 7; i++) {
			cin >> t;
			if (marks[t])
				cnt++;
		}
		ans[cnt]++;
	}

	for (int i = 7; i >= 1; i--)
		cout << ans[i] << " ";
	return 0;
}
